/*
 * @Author: huangyq
 * @Date: 2022-04-06 13:04:09
 * @LastEditTime: 2022-06-14 14:11:47
 * @LastEditors: huangyq
 * @Description: http工具 可根据自己的需求修改文件
 * @FilePath: /vue3-boilerplate-pc-client/src/plugins/httpHelper/index.ts
 */

import { createErrorHandler } from './handler/ErrorHandler'
import {
  createRequestTokenHandler,
  createResponseTokenHandler
} from './handler/TokenHandler'
import createHttpRequest from './instance'
export type { AxiosRequestConfig, AxiosPromise } from 'axios'
export interface IBaseResponse {
  [key: string]: boolean | string | unknown
  success: boolean
  message: string
  code: string
}
export interface IBaseRequest {
  [key: string]: any
}

const toastFunction = createErrorHandler()
const responseTokenHandler = createResponseTokenHandler()
const requestTokenHandler = createRequestTokenHandler()

export default createHttpRequest({
  toastFunction,
  requestTokenHandler,
  responseTokenHandler
})
